package com.cqyc.network.http

import com.cqyc.network.Response
import com.cqyc.network.model.*
import retrofit2.Call
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST

interface Api {
    @POST("/api/indexInfo")
    @FormUrlEncoded
    fun getIndexInfo(@Field("token") token: String = ""): Call<Response<IndexInfo>>

    @POST("/api/login")
    @FormUrlEncoded
    fun logIn(
        @Field("account") account: String,
        @Field("code") code: String
    ): Call<Response<LogoInfo>>

    @POST("/api/mch/index")
    @FormUrlEncoded
    fun getUserInfo(@Field("token") token: String = ""): Call<Response<UserInfo>>

    //获取商品列表
    /**
     * @param keyword 搜索名称
     * @param type 1销量倒叙，2销量升序，3上新，4价格倒叙，5价格升序
     */
    @POST("/api/mch/itemList")
    @FormUrlEncoded
    fun getItemList(
        @Field("page") page:Int,
        @Field("limit") limit:Int,
        @Field("uid") uid: String,
        @Field("keyword") keyword: String,
        @Field("type") type: String
    ): Call<Response<List<GoodsInfo>>>

    //卖家端订单列表
    @POST("/api/mch/tradeList")
    @FormUrlEncoded
    fun tradeList(
        @Field("uid") uid: String,
        @Field("page") page: Int,
        @Field("limit") limit: String = "20"
    ): Call<Response<OrderInfo>>

    //买家端订单列表
    @POST("/api/antApp/tradeList")
    @FormUrlEncoded
    fun tradeListBuy(
        @Field("mch_uid") uid: String,
        @Field("page") page: Int,
        @Field("limit") limit: String = "20"
    ): Call<Response<OrderInfo>>

    //获取公共配置
    @POST("/api/antApp/configInfo")
    @FormUrlEncoded
    fun getConfigInfo(@Field("uid") uid: String = ""): Call<Response<ConfigInfo>>

    /**
     * 公共配置更新
     * @param str 新消息声音提醒，1开启，2关闭
     */
    @POST("/api/antApp/configSave")
    @FormUrlEncoded
    fun setConfig(@Field("new_message_sound") str: String): Call<Response<Any>>

    //获取新的userSig
    @POST("/api/getUserSig")
    @FormUrlEncoded
    fun getUserSig(@Field("token") str: String = ""): Call<Response<String>>

    //查询商品
    @POST("/api/antApp/itemInfo")
    @FormUrlEncoded
    fun findGoods(@Field("item_id") itemId: String = ""): Call<Response<GoodsInfo>>

    //查询店铺 买家端
    @POST("/api/antApp/mchInfo")
    @FormUrlEncoded
    fun findMchInfo(@Field("mch_uid") mchUid: String): Call<Response<ShopInfo>>

    //查询商家信息 卖家端
    @POST("/api/mch/info")
    @FormUrlEncoded
    fun getMchInfo(@Field("mch_uid") mchUid: String = ""): Call<Response<MyShopInfo>>

    //查询会员信息
    @POST("/api/index/queryUserInfo")
    @FormUrlEncoded
    fun queryUserInfo(@Field("user_uid") userUid: String): Call<Response<QueryUserInfo>>

    //版本检查
    @POST("/api/index/appVersion")
    @FormUrlEncoded
    fun appVersion(@Field("user_uid") userUid: String): Call<Response<VersionInfo>>
}